Add SwiftUI native read bindings#845
Conversation
The native binding crate already provides a stable C ABI for text and Markdown export, so the Swift port starts as a thin SwiftPM package over that ABI instead of duplicating parser logic. The wrapper keeps file-based export semantics intact while giving Swift callers typed results and errors. Constraint: Existing portable surface is the bindings/Native C ABI Rejected: Rewrite the parser in Swift | would duplicate the Rust document model before the ABI is proven in apps Confidence: high Scope-risk: narrow Directive: Keep Swift API additions aligned with bindings/Native symbols until an XCFramework packaging step is introduced Tested: cargo build --manifest-path bindings/Native/Cargo.toml Tested: swift test -Xlinker -L../../bindings/Native/target/debug Not-tested: iOS app bundle/XCFramework runtime packaging
Swift app integration needs an Apple-native binary artifact, so the native FFI crate now emits a static library and the release helper assembles device, simulator, and macOS slices into RhwpNative.xcframework with a zipped archive and checksum. Constraint: Xcode consumes native Rust code most cleanly through XCFramework artifacts Rejected: Commit generated XCFramework output | binary release artifacts should stay under ignored dist/swift Confidence: high Scope-risk: narrow Directive: Keep the generated archive out of git; rerun scripts/package-swift-xcframework.sh for release assets Tested: ./scripts/package-swift-xcframework.sh Tested: swift test -Xlinker -L../../bindings/Native/target/debug Not-tested: importing the generated XCFramework into a real iOS app target
Swift app callers need document content in memory, not a TXT export side effect. The native ABI now exposes rhwp_read_text, Swift decodes that into page models, and the package includes a SwiftUI text view that loads an HWP URL and displays extracted pages. Constraint: SwiftUI display should not depend on temporary export files Rejected: Reuse rhwp_export_text for UI display | it writes TXT files and returns paths instead of document content Confidence: high Scope-risk: moderate Directive: Keep read APIs side-effect free; export APIs remain the file-writing surface Tested: cargo test --manifest-path bindings/Native/Cargo.toml Tested: cargo build --manifest-path bindings/Native/Cargo.toml Tested: swift test -Xlinker -L../../bindings/Native/target/debug Tested: ./scripts/package-swift-xcframework.sh Tested: unpacked XCFramework ZIP macOS slice linked to rhwp_read_text against samples/KTX.hwp Not-tested: rendering inside a live iOS simulator app target
…wpDocumentTextView PR #845 (@ubermensch1218, rhwp 첫 PR) cherry-pick. base main → devel 경로 보정하여 cherry-pick. 신규: - bindings/swift/ — SwiftPM package (CRhwpNative modulemap + Rhwp Swift wrapper) - bindings/swift/Sources/Rhwp/Rhwp.swift — RhwpDocument (open/readText/exportText/exportMarkdown) - bindings/swift/Sources/Rhwp/RhwpDocumentTextView.swift — SwiftUI 텍스트 뷰 - bindings/swift/Tests/RhwpTests/ — Swift 테스트 - scripts/package-swift-xcframework.sh — XCFramework 패키징 스크립트 - bindings/Native/src/lib.rs — rhwp_read_text FFI 함수 신규 검증: - cargo test --release --lib: 1246 passed (회귀 0) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…@ubermensch1218 rhwp 첫 PR, base main→devel 경로 보정)
- bindings/swift/Examples/read_text_ffi.swift — rhwp_read_text FFI 예제 (HWP 파일 텍스트를 페이지별 JSON으로 읽어 출력) - bindings/swift/README.md — Examples 섹션 추가 (실행 방법 3가지) 검증: swift bindings/swift/Examples/read_text_ffi.swift → KTX.hwp 27페이지 텍스트 정상 출력 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Welcome to the rhwp project, @ubermensch1218! 🎉 This is your first PR and we really appreciate the initiative — adding a Swift Package wrapper with What was merged
We also added an example script and updated the README as a follow-up:
Branch policy for future Swift/iOS workFor any future Swift or iOS-related PRs, please target the How to run the Swift tests locally# 1. Build the native FFI library
cargo build --manifest-path bindings/Native/Cargo.toml
# 2. Run Swift package tests (macOS)
cd bindings/swift
swift test -Xlinker -L../../bindings/Native/target/debug
# 3. Run the FFI example script (reads samples/KTX.hwp)
cargo build --manifest-path bindings/Native/Cargo.toml --release
swift bindings/swift/Examples/read_text_ffi.swift
# 4. Read a specific file and page
swift bindings/swift/Examples/read_text_ffi.swift samples/aift.hwp 0All 4 Swift tests pass on our environment (macOS, Apple Silicon). Thank you for the contribution, and we look forward to more! If you have questions about the project structure or |
|
Thanks for the detailed note and for preserving authorship. Noted on the branch policy. I’ll target ios/devel for future Swift/iOS-related PRs.
과자
***@***.***
… 2026. 5. 13. 오후 6:36, edward kim ***@***.***> 작성:
edwardkim left a comment (edwardkim/rhwp#845)
Welcome to the rhwp project, @ubermensch1218! 🎉
This is your first PR and we really appreciate the initiative — adding a Swift Package wrapper with RhwpDocumentTextView and XCFramework packaging is a great contribution. We've cherry-picked your changes into the devel branch and synced them to ios/devel.
What was merged
• bindings/swift/ — SwiftPM package (Rhwp wrapper + RhwpDocumentTextView + tests)
• bindings/Native/src/lib.rs — rhwp_read_text FFI function
• scripts/package-swift-xcframework.sh — XCFramework packaging script
• Author preserved: 강정석 ***@***.***>
We also added an example script and updated the README as a follow-up:
• bindings/swift/Examples/read_text_ffi.swift — demonstrates direct FFI usage
• bindings/swift/README.md — Examples section with usage guide
Branch policy for future Swift/iOS work
For any future Swift or iOS-related PRs, please target the ios/devel branch instead of main or devel. The ios/devel branch is where all Apple platform work lives (including our existing iOS app "알한글"). We periodically sync devel → ios/devel to keep Rust core changes in sync.
# When creating a PR for Swift/iOS work:
gh pr create --repo edwardkim/rhwp --base ios/devel --head your-branch --title "..."
How to run the Swift tests locally # 1. Build the native FFI library
cargo build --manifest-path bindings/Native/Cargo.toml
# 2. Run Swift package tests (macOS)
cd bindings/swift
swift test -Xlinker -L../../bindings/Native/target/debug
# 3. Run the FFI example script (reads samples/KTX.hwp)
cargo build --manifest-path bindings/Native/Cargo.toml --release
swift bindings/swift/Examples/read_text_ffi.swift
# 4. Read a specific file and page
swift bindings/swift/Examples/read_text_ffi.swift samples/aift.hwp 0
All 4 Swift tests pass on our environment (macOS, Apple Silicon).
Thank you for the contribution, and we look forward to more! If you have questions about the project structure or ios/devel workflow, feel free to open a discussion or issue.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
Thanks for the detailed note and for preserving authorship. Noted on the branch policy. I’ll target ios/devel for future Swift/iOS-related PRs. |
Summary
rhwp_read_textand exposeRhwpDocumentTextViewfor SwiftUI displayVerification
cargo test --manifest-path bindings/Native/Cargo.tomlcargo build --manifest-path bindings/Native/Cargo.tomlswift test -Xlinker -L../../bindings/Native/target/debug./scripts/package-swift-xcframework.shrhwp_read_textagainstsamples/KTX.hwpRhwpDocumentTextViewand confirmed HWP text rendered on screenNotes